Title Case For Headings by Nathanael Nerode

Version 2.0.220529

Applies title case to room names printed as a heading or in the status line. Creates the printing a heading activity for further customization. Tested with Inform 10.1.0. Requires Undo Output Control by Nathanael Nerode to handle the case of room name printing after UNDO.


Section 1: The Problem
Section 2: The Solution
Section 3: Advanced Solution - the printing a heading activity
Section 4: Making it work right with "Undo" - Include Undo Output Control
Section 5: Changelog

Examples
   
A — Meadow
   
B — The Meadow
   
C — Around the Pond
   
D — People's Rooms


Section 1: The Problem

It is traditional to give rooms titlecased names, like "The Meadow". However, it is also often desirable to put a room into scope. This may be done so that people can say "look at the meadow", or so that people can look at faraway rooms. When the room is in scope, or for other reasons, the room name may be printed in various other contexts, including some of the responses in the Standard Rules. And often we don't want those to be titlecase.

For instance, if you try this, the title in the status line and room description heading will be "Meadow"; but 'take meadow' will print "You would have to get out of the Meadow first."

"Too Much Uppercase"

The Meadow is a room. "This is a meadow."

After deciding the scope of an object (called character):
     Place the location of the character in scope, but not its contents.

And if you try this, 'take meadow' will print "You would have to get out of the meadow first", but the title in the status line and room description heading will be "meadow".

"too much lowercase"

a meadow is a room. "This is a meadow."

After deciding the scope of an object (called character):
     Place the location of the character in scope, but not its contents.

test case with "take meadow / look"

When you start having rooms with possessive names like "John's Hotel Room", it gets even more complicated. You probably want it to be called "the hotel room" in text but "John's Hotel Room" in the status line and headings.

Section 2: The Solution

This extension will convert names like "babbling brook" to "Babbling Brook" (or "box" to "Box", etc.) for the heading at the top of the room description, and for the status line, but otherwise keep them in lowercase. So we will see:

Babbling Brook
This is a location.
> take brook
You would have to get out of the babbling brook first.

The example Meadow does this.

In addition, if a room or other object has the property "title", that will be used for the headings instead. The type "titled room" is provided as a kind of room with a "title" property, but you can also give other kinds a "title" property if you want to.

The examples The Meadow and Near the Pond do this.

Section 3: Advanced Solution - the printing a heading activity

This extension also introduces the "printing a heading" activity.

Printing a heading is active when printing the room name at the top of a room description. It is not active when printing the name of a dark room, which has its own "printing the name of a dark room" activity.

Printing a heading is also active when printing the name of a thing at the top of the visibility threshold. For instance, if you're inside a closed opaque box, the heading should read:

Box But it is not active when printing the name of a container which is not at the top level, so that you will get:
Green Room (in the box)

Printing a heading is also active when printing a name for the status line. (This does not normally have parenthetical expressions on it so I did not special-case them.)

By default, printing a heading will apply title case to the printed name of the object (See "Meadow".) If the object has a "title" property, it will instead print that. (See "The Meadow" and "Near the Pond".) But it can be overridden to print whatever you want.

The example "People's Rooms" implements a complex naming scheme involving possessives, which change depending on who the player character is.

Section 4: Making it work right with "Undo" - Include Undo Output Control

There is one annoying corner case. When "undo" is successfully executed, the room name is printed as a heading. For this extension to process this heading correctly, it is necessary to:

Include Undo Output Control by Nathanael Nerode.

The newest version of Undo Output Control is on the "Friends of I7" extension page on Github. I updated it specifically so that I could fix this bug. If you have trouble including Undo Output Control, you may just be willing to live with the bug.

Section 5: Changelog

2.0.220529: Remove documentation section numbers to allow for automated numbering
2.0.220527: Revise examples to work with automated testing of examples
2.0.220524: Reformat Changelog
2.0.220522: Correct a version number SNAFU
1.2.220522: Example bugfix, remove unnecessary dummy variable, add Changelog
1.2.220521: Proper update to Inform v10
1.2: Partial update to Inform v10
1/170902: Version for inform 6M62

Section 6 - Examples


A
 Example Meadow

The title is Meadow, the name is meadow


B
 Example The Meadow

But we want the title to be *The* Meadow.


C
 Example Around the Pond

A more complex example


D
 Example People's Rooms

Rooms with possessive names

This example lets you play the game as John or Alice, using an initial Pick Identity scene. After picking an identity at the start of the game, the default "yourself" object is removed. The text substitutions adjust the printed names and titles of the dorm rooms to match (so one of them is "Your Dorm Room" and the other is "Alice's Dorm Room" or "John's Dorm Room".

There is one really tricky bit. The Standard Rules will not list an item in the room description if it believes the item has been mentioned already. Using the possessive form of John in the title of the room causes it to be marked as mentioned, so it must be unmentioned before the room description is printed -- or else John will turn invisible when in his own room.

In the Pick Identity scene, it is necessary to run the scene checking rules manually to trigger the scene change at the right time. The initial room description must be deferred until after the identity is chosen, as well.

Note the careful attention to capitalization in the descriptions. The title case in the headings, however, happens automatically.

Test this by looking at all the rooms as John, and then by looking at all the rooms as Alice.

"People's Rooms"

The story author is "Nathanael Nerode".
The release number is 2.
Include Undo Output Control by Nathanael Nerode.
Include Title Case for Headings by Nathanael Nerode.

To say unmention (item - a thing):
     now item is not mentioned;

Pick Identity is a scene.
Pick Identity begins when play begins.
Pick Identity ends when the player is not yourself.

When Pick Identity begins:
     now the command prompt is "Would you like to play as John or Alice? >".

The initial room description rule is not listed in the startup rulebook.

After reading a command when Pick Identity is happening:
     if the player's command matches "Alice":
         now the player is Alice;
         follow the scene changing rules;
     otherwise if the player's command matches "John":
         now the player is John;
         follow the scene changing rules;
     otherwise:
         say "I didn't understand that. Please type 'Alice' or 'John'.";
     reject the player's command.

When Pick Identity ends:
     now the command prompt is ">";
     now yourself is nowhere;
     say line break;
     try looking.

To say (T - a text) capitalized/capitalised:
     let temp be T;
     replace the regular expression "^(\w)" in T with "\u1";
     say T;

To say (O - an object) capitalized/capitalised:
     let temp be "[O]";
     say temp capitalized;

Dormitory Hallway is a room. "This is the hallway of the dormitory. [Dorm room 1 capitalized] is to the west and [dorm room 2] is to the east."

A dorm room is a kind of room.
Occupancy relates various dorm rooms to one person (called the occupant).
The verb to be occupied by means the occupancy relation.
The verb to occupy means the reversed occupancy relation.
Dorm room 1 is occupied by John.
Dorm room 2 is occupied by Alice.

Rule for printing the name of a dorm room (called item) while printing a heading:
     say "[regarding the occupant of item][Possessive] Dorm Room[unmention the occupant]".
Rule for printing the name of a dorm room (called item):
     say "[regarding the occupant of item][possessive] dorm room[unmention the occupant]".

Dorm room 1 is a dorm room.
Dorm room 1 is west of hallway.
The description of dorm room 1 is "[We]['re] in [dorm room 1]. [We] [can] leave to the east."

Dorm room 2 is a dorm room.
Dorm room 2 is east of hallway.
The description of dorm room 2 is "[We]['re] in [dorm room 2]. [We] [can] leave to the west."

John is a man.
The description of John is "[John] [look] no different from last time you saw [them]."
John is in dorm room 1.
Persuasion rule for asking John to try going: persuasion succeeds.

Alice is a woman.
The description of Alice is "[Alice] [look] no different from last time you saw [them]."
Alice is in dorm room 2.
Persuasion rule for asking Alice to try going: persuasion succeeds.